<?php
class Administrator_AjaxController extends QSource_System_Controller_Action{
	public function init(){
		$this->loadTemplate('administrator');
		$auth = Zend_Auth::getInstance();
		$info = $auth->getIdentity();
		$this->view->user_info = $info;
		$request['module'] = $this->_request->getModuleName();
		$request['action'] = $this->_request->getActionName();
		$request['controller'] = $this->_request->getControllerName();
		$this->view->request = $request;
	}
	public function indexAction(){
		
	}
	public function articledisplayAction(){ 
		$model = new Administrator_Model_Article_Article();
		$url = '/administrator/article/index/';
		$num = $this->_request->getParam('num',10);
		$this->view->num = $num;
		$url = $url.'num/'.$num.'/';
		$catergory = $this->_request->getParam('catergory','');
		if($catergory=='')
		{
			$data = $model->getAll();
		}
		else
		{
			$this->view->catergory = $catergory;
			$data = $model->getItemsByCat($catergory);	
		}
		$count = count($data);
		$this->view->count = $count;
		Zend_View_Helper_PaginationControl::setDefaultViewPartial(APPLICATION_PATH.'\modules\administrator\views\pagination.phtml');
		$pa = Zend_Paginator::factory($data);
		$pa->setItemCountPerPage($num);
		$pa->setPageRange(3);
		$current = $this->_request->getParam('page','1');
		$this->view->page = $current;
		$pa->setCurrentPageNumber($current);
		$f0 = array('lifetime'=>3600,'automatic_serialization'=>true);
		$b0 = array('cache_dir'=>APPLICATION_PATH.'/tmp');
		$cache = Zend_Cache::factory('Core','File',$f0,$b0);
		Zend_Paginator::setCache($cache);
		$pa->getCurrentItems();
		$this->view->data = $pa;
		$this->view->url = $url;
		$this->_helper->layout()->disableLayout();
	}
	public function districtAction(){
		$id = $this->_request->getParam('id','');
		$model = new Model_District_District();
		$data = $model->getItemsByProvince($id);
		$this->view->data = $data;
		$this->_helper->layout()->disableLayout();
	}
	public function menuparentAction(){
		$id = $this->_request->getParam('id','');
		$model = new Model_Menu_Menu();
		$data = $model->getItemsByCate($id);
		$this->view->data = $data;
		$this->_helper->layout()->disableLayout();
	} 
	public function editmenuparentAction(){
		$id = $this->_request->getParam('id','');
		$idcat = $this->_request->getParam('idcat','');
		$model = new Model_Menu_Menu();
		$data = $model->getItemsByCateExceptId($idcat,$id);
		$this->view->data = $data;
		$this->_helper->layout()->disableLayout();
	}		
}